﻿using System;
using System.Runtime.InteropServices;

namespace ScenarioFramework.WAPI
{
    public partial class Process
    {
        /// <summary>
        /// Creates the process instance.
        /// </summary>
        /// <param name="sWorkflowName">Name of the s workflow.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "createNewProcessInstance")]
        private static extern String CreateProcessInstance(String sWorkflowName, ref long lProcessID, ref Response response);

        /// <summary>
        /// Starts the process instance.
        /// </summary>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        [DllImport("WAPI.dll", EntryPoint = "startProcessInstance")]
        private static extern void StartProcessInstance(long lProcessID, ref Response response);

        /// <summary>
        /// Starts the process instance in synch way.
        /// </summary>
        /// <param name="iProcessID">The i process ID.</param>
        /// <param name="response">The response.</param>
        [DllImport("WAPI.dll", EntryPoint = "startProcessInSynchWay")]
        private static extern void StartProcessInstanceInSynchWay(long iProcessID, ref Response response);


        [DllImport("WAPI.dll", EntryPoint = "getProcessAttribute")]
        private static extern String GetProcessAttribute(string sAttributeName, long iProcessID, ref Response response);

        /// <summary>
        /// Restarts the process instance.
        /// </summary>
        /// <param name="sActivity">The s activity.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        [DllImport("WAPI.dll", EntryPoint = "restartProcessInstance")]
        private static extern void RestartProcessInstance(String sActivity, long lProcessID, ref Response response);

        /// <summary>
        /// Sets the process instance attributes.
        /// </summary>
        /// <param name="xmlAttributes">The XML attributes.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "setProcessInstanceAttributes")]
        private static extern String SetProcessInstanceAttributes(String xmlAttributes, long lProcessID, ref Response response);

        /// <summary>
        /// Updates the process instance attributes.
        /// </summary>
        /// <param name="xmlAttributes">The XML attributes.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        [DllImport("WAPI.dll", EntryPoint = "UpdateProcessInstanceAttributes")]
        private static extern void UpdateProcessInstanceAttributes(String xmlAttributes, long lProcessID, ref Response response);

        /// <summary>
        /// Gets the process instance attributes.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "getProcessInstanceAttributes")]
        private static extern String GetProcessInstanceAttributes(ref Response response, long lProcessID);

        /// <summary>
        /// Gets the next activity list.
        /// </summary>
        /// <param name="sActivity">The s activity.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "getNextActivityList")]
        private static extern String GetNextActivityList(String sActivity, long lProcessID, ref Response response);

        /// <summary>
        /// Gets the activity result list.
        /// </summary>
        /// <param name="sActivity">The s activity.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "getActivityResultList")]
        private static extern String GetActivityResultList(String sActivity, long lProcessID, ref Response response);

        /// <summary>
        /// Gets the process instance.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "getProcessInstance")]
        private static extern String GetProcessInstance(ref Response response, long lProcessID);

        [DllImport("WAPI.dll", EntryPoint = "LoadProcessInstance")]
        private static extern String LoadProcessInstance(ref Response response, long lProcessID);

        /// <summary>
        /// Gets only the process instance tag. Doesn't return attributes and activities.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <param name="lProcessID">The l process ID.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "getProcessHeader")]
        private static extern String GetProcessHeader(ref Response response, long lProcessID);

        [DllImport("WAPI.dll", EntryPoint = "getNewProcessHeader")]
        private static extern String GetNewProcessHeader(ref Response response, long lProcessID);

        [DllImport("WAPI.dll", EntryPoint = "getProcessStatus")]
        private static extern String GetProcessStatus(ref Response response, long lProcessID);

        /// <summary>
        /// Gets the processes.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        [DllImport("WAPI.dll", EntryPoint = "getProcesses")]
        private static extern String GetProcesses(ref Response response);

        /// <summary>
        /// Gets the reports.
        /// </summary>
        /// <param name="lProcessID">The l process ID.</param>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        [DllImport("WAPI.Dll", EntryPoint = "getReports")]
        private static extern String GetReports(long lProcessID, ref Response response);
    }
}
